package com.totcy.atom.adapter;

import android.content.Context;

import com.totcy.atom.R;
import com.totcy.atom.bean.HeWeatherLifeStyle;
import com.totcy.baselibrary.adapter.BaseRecyleAdapter;
import com.totcy.baselibrary.adapter.BaseViewHolder;

import java.util.List;


/**
 * description : 天气生活指数
 *
 * @author : Totcy
 * @date : 2018/1/29 16:55
 * @update : 2018/1/29
 */

public class LifeIndexAdapter extends BaseRecyleAdapter<HeWeatherLifeStyle> {

    public LifeIndexAdapter(Context mContext, List<HeWeatherLifeStyle> mDatas) {
        super(mContext, mDatas, R.layout.item_life_index);
    }

    @Override
    protected void convert(Context mContext, BaseViewHolder holder, HeWeatherLifeStyle heWeatherLifeStyle) {
        //生活指数类型 comf：舒适度指数、cw：洗车指数、drsg：穿衣指数、flu：感冒指数、
        // sport：运动指数、trav：旅游指数、uv：紫外线指数、air：空气污染扩散条件指数

        holder.setText(R.id.tv_lifeIndexValue, heWeatherLifeStyle.getBrf());
        holder.setText(R.id.tv_lifeIndexDesc, heWeatherLifeStyle.getTxt());
        TypeBean typeBean = getName(heWeatherLifeStyle.getType());
        holder.setText(R.id.tv_lifeIndexName, typeBean.name);
        holder.setImageResource(R.id.iv_lifeIndexIcon,typeBean.iconRes);
    }

    private TypeBean getName(String type) {
        TypeBean result = new TypeBean();
        switch (type) {

            case "comf":
                result.name = "舒服度";
                result.iconRes = R.drawable.icon_dressing;
                break;
            case "cw":
                result.name = "洗车";
                result.iconRes = R.drawable.icon_washcar;
                break;
            case "drsg":
                result.name = "穿衣";
                result.iconRes = R.drawable.icon_dressing;
                break;
            case "flu":
                result.name = "感冒";
                result.iconRes = R.drawable.icon_cold;
                break;
            case "sport":
                result.name = "运动";
                result.iconRes = R.drawable.icon_sport;
                break;
            case "trav":
                result.name = "旅游";
                result.iconRes = R.drawable.icon_tourism;
                break;
            case "uv":
                result.name = "紫外线";
                result.iconRes = R.drawable.icon_uv;
                break;
            case "air":
                result.name = "空气污染扩散";
                result.iconRes = R.drawable.icon_air;
                break;
            default:
                result.name = "";
                break;
        }

        return result;
    }

    private class TypeBean {
        public String name;
        public int iconRes;
    }
}
